package com.heima.zuoye.day08.timu3;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

public class Demo1 {
    public static void main(String[] args) {
        List<SanGuo> sg = new ArrayList<>();
        SanGuo sg1 = new SanGuo("刘备", "字玄德");
        SanGuo sg2 = new SanGuo("诸葛亮", "字孔明");
        SanGuo sg3 = new SanGuo("曹操", "字孟德");
        SanGuo sg4 = new SanGuo("孙权", "字仲谋");
        SanGuo sg5 = new SanGuo("关羽", "字云长");
        SanGuo sg6 = new SanGuo("张飞", "字翼德");
        SanGuo sg7 = new SanGuo("赵云", "字子龙");
        SanGuo sg8 = new SanGuo("乐进", "字文谦");
        SanGuo sg9 = new SanGuo("李典", "字曼成");
        SanGuo sg10 = new SanGuo("曹仁", "字子孝");
        SanGuo sg11 = new SanGuo("曹洪", "字子廉");

        Collections.addAll(sg, sg1, sg2, sg3, sg4, sg5, sg6, sg7, sg8, sg9, sg10, sg11);
        System.out.println(sg);

        Map<String, String> map = sg.stream().collect(Collectors.toMap(
                sanGuo -> {
                    return sanGuo.getName();
                }, sanGuo -> {
                    return sanGuo.getZihao();
                }
        ));
        map.forEach(new BiConsumer<String, String>() {
            @Override
            public void accept(String s, String s2) {
                System.out.println(s + ":" + s2);
            }
        });
    }
}
